# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-xdot
pkgname=('python2-xdot' 'python-xdot')
_pkgname=xdot
pkgver=1.4
_pyver=3.13
pkgrel=3
pkgdesc='Interactive viewer for Graphviz dot files.'
arch=('any')
url='https://pypi.org/project/xdot/#files'
license=('LGPL')
makedepends=('python2-setuptools' 'python-setuptools')
conflicts=('xdot')
provides=('xdot')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('2aeec1ddc72f478524f1c19efe05a31f5aa112d1b814c7106c8b95e4cdbd06c29bc197fe6220696b522ed8b486f29b728584e4e977ae1ec0d92672675444c73a')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-xdot() {
  depends=('python2' 'graphviz' 'pygtk')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  find "$pkgdir/usr/lib/python2.7/site-packages/" -type f -exec chmod 644 {} \;

  mv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/bin/${_pkgname}2"
}

package_python-xdot() {
  depends=('python' 'graphviz' 'pygtk')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  find "$pkgdir/usr/lib/python$_pyver/site-packages/" -type f \
    -exec chmod 644 {} \;
}

